<template>
  <Form class="loginForm" ref="loginForm" :model="form" :rules="rules" @keydown.enter.native="handleSubmit">
    <FormItem prop="userName">
      <Input v-model="form.userName" placeholder="请输入用户名" style="height: 50px;">
        <span slot="prefix">
          <img src="../../assets/images/username.png" width="21" style="vertical-align:middle;">
        </span>
      </Input>
    </FormItem>
    <FormItem prop="password" style="height: 50px;">
      <Input type="password" v-model="form.password" placeholder="请输入密码">
        <span slot="prefix">
          <img src="../../assets/images/password.png" width="24" style="vertical-align:middle;">
        </span>
      </Input>
    </FormItem>
		<FormItem prop="password" style="margin-top:-26px;">
		  <Checkbox v-model="single">  记住账号</Checkbox>
		</FormItem>
    <FormItem>
      <Button @click="handleSubmit" type="primary" long>登录</Button>
    </FormItem>
  </Form>
</template>
<script>
export default {
  name: 'LoginForm',
  props: {
    userNameRules: {
      type: Array,
      default: () => {
        return [
          { required: true, message: '账号不能为空', trigger: 'blur' }
        ]
      }
    },
    passwordRules: {
      type: Array,
      default: () => {
        return [
          { required: true, message: '密码不能为空', trigger: 'blur' }
        ]
      }
    }
  },
  data () {
    return {
      form: {
        userName: 'super_admin',
        password: '',
				single:false
      }
    }
  },
  computed: {
    rules () {
      return {
        userName: this.userNameRules,
        password: this.passwordRules
      }
    }
  },
  methods: {
    handleSubmit () {
      this.$refs.loginForm.validate((valid) => {
        if (valid) {
          this.$emit('on-success-valid', {
            userName: this.form.userName,
            password: this.form.password
          })
        }
      })
    }
  }
}
</script>
<style scoped>
	.loginForm >>> .ivu-input{
		height:50px;
		text-indent: 20px;
		font-size:16px;
		border-radius:10px;
	}
	.loginForm >>> .ivu-input-prefix{
		width:60px;
		line-height:50px;
	}
	.loginForm >>> .ivu-btn{
		height:50px;
		font-size:16px;
		border-radius:10px;
	}
	.loginForm >>> .ivu-form-item{
		margin-bottom:40px;
	}
	.loginForm >>> .ivu-checkbox-wrapper{
		font-size:14px;
		padding-left:10px;
		border-radius:10px;
	}
	.loginForm >>> .ivu-checkbox-inner{
		width:16px;
		height:16px;
		border-radius:4px;
	}
	.loginForm >>> .ivu-checkbox{
		padding-right:6px;
	}
	.loginForm >>> .ivu-checkbox-checked .ivu-checkbox-inner:after{
		width:5px;
		height:10px;
	}
</style>
